﻿using System.Collections.Generic;

namespace SegmentDisplay.Common.Digit16
{
    public static class ValueSet16
    {
        public static Dictionary<string, Values16> Alphabet = new Dictionary<string, Values16>();

        static ValueSet16()
        {
            Alphabet.Add("Empty", Values16.SimbolEmpty);
            Alphabet.Add("0", Values16.Digit0);
            Alphabet.Add("1", Values16.Digit1);
            Alphabet.Add("2", Values16.Digit2);
            Alphabet.Add("3", Values16.Digit3);
            Alphabet.Add("4", Values16.Digit4);
            Alphabet.Add("5", Values16.Digit5);
            Alphabet.Add("6", Values16.Digit6);
            Alphabet.Add("7", Values16.Digit7);
            Alphabet.Add("8", Values16.Digit8);
            Alphabet.Add("9", Values16.Digit9);
            Alphabet.Add("A", Values16.SimbolA);
            Alphabet.Add("B", Values16.SimbolB);
            Alphabet.Add("C", Values16.SimbolC);
            Alphabet.Add("D", Values16.SimbolD);
            Alphabet.Add("E", Values16.SimbolE);
            Alphabet.Add("F", Values16.SimbolF);
            Alphabet.Add("G", Values16.SimbolG);
            Alphabet.Add("H", Values16.SimbolH);
            Alphabet.Add("I", Values16.SimbolI);
            Alphabet.Add("J", Values16.SimbolJ);
            Alphabet.Add("K", Values16.SimbolK);
            Alphabet.Add("L", Values16.DigitL);
            Alphabet.Add("M", Values16.SimbolM);
            Alphabet.Add("n", Values16.Digitn);
            Alphabet.Add("N", Values16.SimbolN);
            Alphabet.Add("o", Values16.Digito);
            Alphabet.Add("O", Values16.DigitO);
            Alphabet.Add("P", Values16.SimbolP);
            Alphabet.Add("Q", Values16.SimbolQ);
            Alphabet.Add("R", Values16.SimbolR);
            Alphabet.Add("S", Values16.SimbolS);
            Alphabet.Add("T", Values16.SimbolT);
            Alphabet.Add("U", Values16.SimbolU);
            Alphabet.Add("V", Values16.SimbolV);
            Alphabet.Add("W", Values16.SimbolW);
            Alphabet.Add("X", Values16.SimbolX);
            Alphabet.Add("Y", Values16.SimbolY);
            Alphabet.Add("Z", Values16.SimbolZ);
            return;
        }

        public static Values16 GetValue(string simbol)
        {
            Values16 result = Values16.SimbolEmpty;
            if(!string.IsNullOrEmpty(simbol))
            {
                string invariant = simbol.Trim().ToUpper();
                if (invariant.Length == 1)
                    Alphabet.TryGetValue(invariant, out result);
                else if (invariant.Equals("EMPTY"))
                    result = Values16.SimbolEmpty;
                else
                    result = Values16.SimbolEmpty;
            }
            return result;
        }
    }
}
